package com.tjcu.action;

import com.opensymphony.xwork2.ActionSupport;
import com.tjcu.entity.Clazz;
import com.tjcu.entity.Group;
import com.tjcu.service.GroupService;
import com.tjcu.service.impl.GroupServiceImpl;

import java.util.Date;
import java.util.List;

/**
 * @author 王恒杰
 * @version 1.0
 * @date 2021/11/2 20:46
 * @email 1078993387@qq.com
 * @Address 天津
 * @Description:
 */
public class GroupAction extends ActionSupport {
    private  List<Clazz> list;
    private  List groupAndClass;
    private Clazz clazz;
    private Group group;
    /**
     * 添加小组
     */
    public String addGroup() {
        //调用业务
        GroupService groupService = new GroupServiceImpl();
        //    小组实体类：gid， gname， gtime，clazz;
        group.setGtime(new Date());
        System.out.println(clazz.getClazzId());
        Group group1 = new Group(null, this.group.getGname(), this.group.getGtime(), clazz);
        System.out.println(group1);
        groupService.addGroup(group1);
        return SUCCESS;
    }

    /**
     * 删除小组
     */
    public String dropGroup() {
        //调用业务
        GroupService groupService = new GroupServiceImpl();
        groupService.dropGroup(group.getGid());
        return SUCCESS;
    }

    /**
     * 展示小组信息
     */
    public String showGroupAndClazz() {
        //调用业务
        GroupService groupService = new GroupServiceImpl();
        groupAndClass = groupService.showGroupAndClass();
        System.out.println(groupAndClass);
        return SUCCESS;
    }

    /**
     * 展示班级名称
     */
    public String ShowClazzName() {
        //调用业务
        GroupService groupService = new GroupServiceImpl();
        list = groupService.showClazzName();
        return SUCCESS;
    }

    public List<Clazz> getList() {
        return list;
    }

    public void setList(List<Clazz> list) {
        this.list = list;
    }

    public List getGroupAndClass() {
        return groupAndClass;
    }

    public void setGroupAndClass(List groupAndClass) {
        this.groupAndClass = groupAndClass;
    }

    public Clazz getClazz() {
        return clazz;
    }

    public void setClazz(Clazz clazz) {
        this.clazz = clazz;
    }

    public Group getGroup() {
        return group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }
}
